package com.example.schedulemanager.viewmodel;

import android.app.Application;

import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import com.example.schedulemanager.model.Schedule;
import com.example.schedulemanager.repository.ScheduleRepository;

import java.util.List;
import java.util.function.Consumer;

public class ScheduleViewModel extends AndroidViewModel {
    
    private ScheduleRepository repository;
    private LiveData<List<Schedule>> allSchedules;
    
    public ScheduleViewModel(Application application) {
        super(application);
        repository = new ScheduleRepository(application);
        allSchedules = repository.getAllSchedules();
    }
    
    public void insert(Schedule schedule, Consumer<Long> callback) {
        repository.insert(schedule, callback);
    }
    
    public void update(Schedule schedule) {
        repository.update(schedule);
    }
    
    public void delete(Schedule schedule) {
        repository.delete(schedule);
    }
    
    public LiveData<List<Schedule>> getAllSchedules() {
        return allSchedules;
    }
    
    public LiveData<List<Schedule>> getSchedulesByDate(String date) {
        return repository.getSchedulesByDate(date);
    }
    
    public LiveData<List<Schedule>> getUpcomingSchedules(String currentDate) {
        return repository.getUpcomingSchedules(currentDate);
    }
    
    public void getScheduleById(int id, Consumer<Schedule> callback) {
        repository.getScheduleById(id, callback);
    }
    
    public void updateCompletionStatus(int id, boolean completed) {
        repository.updateCompletionStatus(id, completed);
    }
} 